var CompanyMaterialType = function (companyMaterialType) {
  //继承BaseModel
  BaseModel.call(this);
  var self = this;
  var copyFields = ['id', 'materialType', 'isReadColor', 'company', 'isSelfAdded', 'status', 'createUser', 'createTime', 'lastModifier',
    'lastModifiedTime', 'defaultWarehouse', 'createOrderIsShow'
  ];
  var fn = {
    //初始化属性
    initData: function (companyMaterialType) {
      if (companyMaterialType === undefined) {
        companyMaterialType = {};
      }
      self.setDataFromObj(companyMaterialType, copyFields, '');
      if (SysUtil.isEmptyObjct(companyMaterialType)) {
        self.isReadColor = 1;
        self.status = 1;
        self.defaultWarehouse = 1;
        self.createOrderIsShow = 1;
      }
    },

    getErrorMsg: function (code) {
      var errorObj = {
        isReadColor: "请选择是否读取颜色",
        materialType: "请选择物料类型",
        defaultWarehouse: "请选择仓位",
        createOrderIsShow: "请选择是否在制单页面显示"
      };
      return errorObj[code];
    }
  };

  this.checkValid = function () {
    var requiredFields = ['isReadColor', 'materialType', 'defaultWarehouse', 'createOrderIsShow'];
    if (!CheckVaildUtil.checkNullValue(requiredFields, this, fn.getErrorMsg)) {
      return false;
    }
    return true;
  };

  this.getObject = function (type) {
    var fields = ['materialType', 'isReadColor', 'company', 'isSelfAdded', 'status', 'createUser', 'createTime', 'lastModifier',
      'lastModifiedTime', 'defaultWarehouse', 'createOrderIsShow'
    ];
    var postData = {};
    if (this.id !== '') {
      postData.id = this.id;
    }
    this.setPostData(postData, fields);
    return postData;
  };

  fn.initData(companyMaterialType);
};
